#include <iostream>

struct Entity
{
    /* data */
    // 使用static修饰的类成员变量在使用前需现在全局进行申明，类似于命名空间;
    static int x, y;

    // 用static 修饰成员方法时，静态方法无法引用类中的非静态成员变量；
    static void print()
    {
        std::cout << Entity::x << "," << Entity::y << std::endl;
    }
};
int Entity::x;
int Entity::y;

class Singleton
{
    // private:
    //     static Singleton* s_instance;

public:
    static Singleton &Get()
    {
        static Singleton s_instance;
        return s_instance;
    }
    void Hello() { std::cout << "hello" << std::endl; }
};

void Function()
{
    // 在方法中设置静态变量，相当于只能通过该方法调用的全局变量；
    static int i = 0;
    i++;
    std::cout << i << std::endl;
};

int main()
{
    /*
    Entity::x = 5;
    Entity::y = 8;
    std::cout << Entity::x <<','<< Entity::y <<std::endl;
    */
    // Entity::x = 10;
    // Entity::y = 11;
    // Entity::print();

    Singleton::Get().Hello();

    return 0;
}